package com.newmainsoftech.aspectjutil.eventmanager.testmodels;

import com.newmainsoftech.aspectjutil.adviseutil.Util;
import com.newmainsoftech.aspectjutil.eventmanager.EventInfo;
import com.newmainsoftech.aspectjutil.eventmanager.label.EventListener;
import com.newmainsoftech.aspectjutil.eventmanager.label.PreEvent;

@EventListener
public class PreEventRecipient {
	// For SampleEventClass.CalculationEvent -----------------------------------------------------
	@PreEvent( value={SampleEventClass.CalculationEvent.class}, amongInstancesInThread=false)
	public static void staticListenerOfCalculationStart( EventInfo eventInfo) {
		EventTraceSupporter.getEventTraceList().add( 
				Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0)
				);
		EventTraceSupporter.saveEventInfo( eventInfo);
	}
	
	@PreEvent( value={SampleEventClass.CalculationEvent.class}, amongInstancesInThread=true)
	private void onCalculationStart( EventInfo eventInfo) {
		EventTraceSupporter.getEventTraceList().add( 
				Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0)
				);
		EventTraceSupporter.saveEventInfo( eventInfo);
	}
	// -------------------------------------------------------------------------------------------
	
	// For SampleEventClass.PriceChange ----------------------------------------------------------
	@PreEvent( value={SampleEventClass.PriceChange.class})
	public static void staticListenerOfPriceChangeStart( EventInfo eventInfo) {
		EventTraceSupporter.getEventTraceList().add( 
				Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0)
				);
		EventTraceSupporter.saveEventInfo( eventInfo);
	}
	
	@PreEvent( value={SampleEventClass.PriceChange.class})
	private void onPriceChangeStart( EventInfo eventInfo) {
		EventTraceSupporter.getEventTraceList().add( 
				Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0)
				);
		EventTraceSupporter.saveEventInfo( eventInfo);
	}
	// -------------------------------------------------------------------------------------------
}
